﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Verse;

namespace SZ.Mech
{
    public class HediffCompProperties_PsychicRegeneration: HediffCompProperties
    {
        public float psychicRegeneration = 0.00125f;
        public HediffCompProperties_PsychicRegeneration()
        {
            this.compClass = typeof(HediffComp_PsychicRegeneration);
        }
    }
    public class HediffComp_PsychicRegeneration : HediffComp
    {
        private int ticks = 0;
        public HediffCompProperties_PsychicRegeneration Props
        {
            get
            {
                return props as HediffCompProperties_PsychicRegeneration;
            }
        }

        public override void CompPostTick(ref float severityAdjustment)
        {
            base.CompPostTick(ref severityAdjustment);

            if (ticks >= 60)
            {
                ticks = 0;
                Pawn.psychicEntropy.OffsetPsyfocusDirectly(Props.psychicRegeneration);
            }
            ticks++;
        }

        public double PsyfocusRegInPercentPerHour => Math.Round(Props.psychicRegeneration * 100 * 40f, 2);
        public override string CompTipStringExtra => $"Psyfocus regeneration: {PsyfocusRegInPercentPerHour}% / h".Translate();

        public override void CompExposeData()
        {
            base.CompExposeData();
            Scribe_Values.Look(ref ticks, "ticks", 0);
        }
    }
}
